﻿/*
#------------------------------------------------------------------------------
#-- Program Name:	[dbo].[spGetDifferentialBackupFileName]
#-- Purpose:		Gets the full file name/path for a differential backup.
#--	Last Update:	06/21/2011
#--					For a complete history - please review comments in Version
#--					Control.
#-- Called By:		[dbo].[spBackupDifferential]
#------------------------------------------------------------------------------
*/
CREATE PROCEDURE [dbo].[spGetDifferentialBackupFileName]
(
	@database_name				sysname,
	@backup_directory_name		varchar(8000)		OUTPUT
)
AS
BEGIN
	--- Declare Local Variables
	DECLARE	@dated_backup varchar(8000), @file_name varchar(8000)

	--- Determine the Backup Part names
	EXEC	dbo.spGetBackupDirectory	@database_name = @database_name, 
										@backup_directory_name = @backup_directory_name OUTPUT	
	SELECT	@dated_backup = REPLACE(REPLACE(REPLACE(CONVERT(varchar(50), GETDATE(), 120), '-', ''), ':' , ''), ' ' , ''),
			@file_name = @database_name + '_diff_' + @dated_backup + '.bak'

	--- Return the name of the Backup File
	SELECT	@backup_directory_name = @backup_directory_name + @file_name
END
